﻿

namespace Oddo.Concept.Crm.Common.Presentation.ViewModels
{
    using Microsoft.Practices.Prism.Modularity;
    using Microsoft.Practices.Prism.UnityExtensions;
    using Oddo.Concept.Crm.Common.ViewModels;
    using Oddo.Concept.Crm.Common.Presentation.Infrastructure;

    public class SplashViewModel : ViewModelBase
    {
        private string _progress = "Loading in progress...";

        public SplashViewModel()
        {
            var manager = this.Container.TryResolve<IModuleManager>();
            manager.LoadModuleCompleted += (s, e) =>
                {
                    Progress = string.Format("{0} loaded", e.ModuleInfo.ModuleName);
                };
        }

        public string Progress
        {
            get { return _progress; }
            set
            {
                _progress = value;
                NotifyPropertyChanged("Progress");
                DispatcherHelper.DoEvents();
            }
        }
    }
}